<form action="" method="post" class="form_single">
  {include file="layout/top"/}
    <div class="box">
      <div class="box-body">
        <div class="col-md-6">
            <div class="form-group">
                <label>{$msg}</label>
                <span class="">（请选择xlsx格式文件）</span>
                <br/>
                {assign name="file_id" value="$info.file_id|default='0'" /}
                {:widget('file/index', ['name' => 'file_id', 'value' => $file_id, 'type' => 'file'])}
            </div>
          </div>
      <div class="box-footer">
        
        <button  type="button" class="btn ajax-submit" id="{$type}" data-style="slide-up" target-form="form_single" style="color:#fff;background:#3c8dbc;">
            <span class="ladda-label"><i class="fa fa-send"></i> 确 定</span>
        </button>
        {if condition="$type eq 1"}
        <button  type="button" class="btn xiazai" id="{$type}" data-style="slide-up" target-form="form_single" style="color:#fff;background:#3c8dbc;">
            <span class="ladda-label"><i class="fa fa-download"></i> 模板下载</span>
        </button>
        {/if}
      </div>
    </div>
    <script src="__STATIC__/module/admin/laydate/layer.js"></script>
    <script src="__STATIC__/module/admin/js/init_body.js"></script>
    <script src="__STATIC__/module/admin/ext/adminlte/dist/js/app.min.js"></script>
    <script src="__STATIC__/module/admin/ext/adminlte/dist/js/init.js"></script>
    <script src="__STATIC__/module/common/toastr/toastr.min.js"></script>
    <script src="__STATIC__/module/admin/ext/btnloading/dist/spin.min.js"></script>
    <script src="__STATIC__/module/admin/ext/btnloading/dist/ladda.min.js"></script>
    <script src="__STATIC__/module/admin/ext/remodal/remodal.min.js"></script>
    <script src="__STATIC__/module/admin/ext/adminlte/plugins/iCheck/icheck.min.js"></script>
    <script src="__STATIC__/module/admin/js/onebase.js"></script>
    <script type="text/javascript">
      $('.ajax-submit').click(function(){
        var urls=$('.upload-pre-file').find('a').attr('href');
        var test_url=urls.replace('picture','file');
        var id=$(this).attr('id');
        if(id==0){
          href='/admin/staff/staffrelation.html';
        }else{
          href='/admin/staff/stafflist.html';
        }
        layer.load(1, {
          shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        $.post('/admin/staff/staffDataImport.html',{test_url:test_url,type:id},
          function(data){
            console.log(data);
            layer.closeAll('loading'); 
            if(data.code==1){
              layer.msg(data.msg);
              setInterval(function(){
                parent.window.location.href=href
              },2000)
            }else{
              layer.msg(data.msg);
            }
        })
      })
      
      $('.xiazai').click(function(){

        var id=$(this).attr('id');
        if(id==1){
          href='http://erp.dscl518.com/yghmc.xlsx';
          window.open(href);
        }else{
          layer.msg('导出的相应表格为模板');
        }
      })
    </script>
</form>
